package online.hxstart.code.dataalgorithm.chapter1;

import java.util.HashMap;
import java.util.Map;

/**
 * @author huxing
 * @date 19-3-29 星期五 上午10:44
 * @describe
 */
public class Try1 {

    public void test01() {
        //byte 与short经行运算必须强制类型转换
        byte a1, b1 = 1, c1 = 2;
        a1 = (byte)(b1 + c1);

        System.out.println(a1);
        short a2, b2 = 1, c2 = 2;
        a2 = (short)(b2 + c2);
        System.out.println(a2);

        int i = 2147483647, j = i + 1;
        System.out.println(j);
        System.out.println(Long.toString(j, 2));

        char ch = '\u12ab';
        System.out.println(ch);
        ch = '\n';
        System.out.println(ch);

        //十进制的83 ASCII码的‘S’  \ddd 八进制
        ch = '\123';
        System.out.println(ch);
        ch = '胡';
        System.out.println(ch);

        int i1 = 123;
        System.out.println(i1);
        //十进制的83   0打头
        int j1 = 0123;
        System.out.println(j1);

        long p = 0x123L;
        System.out.println(p);

        //十六进制
        int k = 0x123a;
        System.out.println(k);
        float f = 213.321F;
        System.out.println(f);
    }

    public void test2() {
        int x, y, z;
        x = y = z = 1;
        x = x + 1;
        x += 1;

        x = 5;
        y = 6 + x++;
        System.out.println(y);
        System.out.println(x);

        int n = -4;
        //右移
        int m = n >> 1;
        System.out.println(m);
        m = n >>> 1;
        System.out.println(m);
    }

    public void test3(double random) {
        double test = 0.5D;
        String s;
        if (random > test / 2) {
            s = "会断送倒霉死了；阿莫多撒是；来的撒旦；1大撒旦撒旦";
        } else if (random > test / 2 && random < test) {
            s = "222";
        } else {
            s = "32132大撒旦";
        }
        System.out.println(random > test);

        /*byte, char, short or int  枚举类型 1.7以后支持String*/
        System.out.println(s.hashCode());
        switch (s) {
            case "会断送倒霉死了；阿莫多撒是；来的撒旦；1大撒旦撒旦":
                System.out.println("会断送");
                break;
            case "222":
                System.out.println("222");
                break;
            case "32132大撒旦":
                System.out.println("32132大撒旦");
                break;
            default:
                System.out.println("default");
        }
        Map<String, Object> map = new HashMap<>(2);
        map.put("dsad", s);
        map.put(s, "ddddddd");
        System.out.println(map);
    }

    public static void main(String[] args) {
    Try1 t = new Try1();
    /*t.test1();*/
    /*t.test2();*/

    double var1 = Math.random();
        t.test3(var1);


    }

}
